package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.wemedia.service.WmCountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Dikk
 */
@RestController
@RequestMapping("/api/v1/statistics")
public class WmCountController {

    @Autowired
    private WmCountService wmCountService;

    /**
     * 查询文章数据统计
     *
     * @param beginDate
     * @param endDate
     * @return
     */
    @GetMapping("/newsDimension")
    public ResponseResult countNum(@RequestParam String beginDate, @RequestParam String endDate) {
        return wmCountService.countNum(beginDate, endDate);
    }

    /**
     * 分页查询文章列表数据
     *
     * @param beginDate
     * @param endDate
     * @param page
     * @param size
     * @return
     */
    @GetMapping("/newsPage")
    public PageResponseResult newsPage(@RequestParam String beginDate, @RequestParam String endDate,
                                       @RequestParam Integer page, @RequestParam Integer size) {
        // 调用 wmCountService 中的 newsPage 方法进行分页查询新闻数据
        return wmCountService.newsPage(beginDate, endDate, page, size);
    }
}
